package cruxgrpc

import (
	"fmt"
	"google.golang.org/grpc"
	"net"
)

func Register(port int64, head func(s *grpc.Server)) {
	// 1.监听
	listener, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
	if err != nil {
		fmt.Printf("监听异常:%s\n", err)
	}
	fmt.Printf("监听端口：%v\n", port)
	// 2.实例化gRPC
	s := grpc.NewServer()
	head(s)
	s.Serve(listener)
}
